<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

// var arr = [{username:'张三',age:20,gender:"男"},{username:'李四',age:25,gender:"男"},{username:'王五',age:21,gender:"男"},{username:'赵四',age:22,gender:"男"}];

// arr.sort(function(a,b){
//     // return a.age - b.age;
//     return b.age - a.age;
// })
// console.log(arr);



// 按照年龄排序 
// var arr = [1,3,2,4,5,23,45,16];
// // arr.sort();  // 必须传回调函数 ,如果不传函数 ，根据ASSCI排序 
// arr.sort(function(a,b){
//     // return a - b;
//     return b - a;
// })
// console.log(arr);



    </script>
</body>
</html>